package main.niit.dao;

import main.niit.pojo.bean;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

public class Get5 {
    public List<bean> getvalue5(Connection connection, Statement statement, ResultSet resultSet, String name) {
//        List<bean1> beans = new ArrayList<>();
//        try {
//            statement = connection.createStatement();
//            resultSet = statement.executeQuery("SELECT*FROM PRM order by score asc limit 6 ");
//            while (resultSet.next()) {
//                bean1 bean1 = new bean1();
//                bean1.setName1(resultSet.getString("name1"));
//                bean1.setName2(resultSet.getString("name2"));
//                bean1.setValue(resultSet.getString("score"));
//                beans.add(bean1);
//            }
//        } catch (SQLException e) {
//            throw new RuntimeException(e);
//        }
//        return beans;
        List<bean> beans = new ArrayList<>();
        try {
            statement = connection.createStatement();
            //resultSet = statement.executeQuery("select * from aera_top3 WHERE city_name  LIKE '%" + name + "%' order by score asc limit 3 ");
            resultSet = statement.executeQuery("select * from ad_province_top3 ");
            while (resultSet.next()) {
                bean bean1 = new bean();
                bean1.setName(resultSet.getString("adid"));
                bean1.setValue(resultSet.getString("clickCount"));
                beans.add(bean1);
            }
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
        return beans;
    }
}
